package com.hurt.competition.admin.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hurt.competition.admin.dto.StudentReq;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface StudentMapper {
    /**
     * 分页查询所有学生信息
     * @param page
     * @return List<Student>
     */
    @Select("select * from player_info")
    IPage<StudentReq> findAll(Page page);

    @Select("select * from player_info where p_id = #{p_id}")
    StudentReq findById(Integer id);

    @Delete("delete from player_info where p_id = #{p_id}")
    int deleteById(Integer id);

    /**
     *更新所有学生信息
     * @param student 传递一个对象
     * @return 受影响的记录条数
     */
    @Update("update player_info set name = #{name},sex = #{sex},age = #{age},phone = #{phone}," +
            "email = #{email} " + "where p_id = #{p_id}")
    int update(StudentReq student);

    /**
     * 更新密码
     * @param student
     * @return 受影响的记录条数
     */
    @Update("update student set pwd = #{pwd} where studentId = #{studentId}")
    int updatePwd(StudentReq student);
}
